﻿
namespace MskEdit.Sdk
{
    public static class SdkBitAlgoritms {
        
        public static int BitCount( int value ) {
            int bitCount = 0 ;
            for ( int i = 0 ; i < sizeof( int ) ; ++i )
                bitCount += ( value >> i )%2 ;
            return bitCount ;        
        }

        public static int BitLsbPos( int value ) {
            for ( int i = 0 ; i < sizeof( int ) ; ++i )
                if ( ( ( value >> i )%2 ) != 0 )
                    return i + 1 ;
            return 0 ;        
        }
        
    }
}
